package com.qf.oop;

import java.util.Random;

/**
 * 创建一个父类：Hero ，属性有 名字，力量，智力，敏捷， 方法有 徒手攻击（攻击力=力量的上下百分之20）
 */
public class Hero {

    String name; //名字

    int power; //力量

    int intelligence; //智慧

    int dex; //Dexterity or Agility 敏捷


    /**
     * 徒手攻击
     *
     * @return 返回造成伤害. 攻击力=力量的上下百分之20
     */
    public double attack() {
        Random random = new Random();
        double r = (double) random.nextInt(20) / 100 + 1;

        System.out.println("发动一次普通攻击,攻击力为:" + this.power * r);

        return this.power * r;
    }

    public void printValue() {
        System.out.print("名字:" + this.name);
        System.out.print(" 力量:" + this.power);
        System.out.print(" 智慧:" + this.intelligence);
        System.out.print(" 敏捷:" + this.dex);
    }

    public Hero() {
        this("xiaobing", 10, 10, 10);
    }

    public Hero(String name, int power, int intelligence, int dex) {
        this.name = name;
        this.power = power;
        this.intelligence = intelligence;
        this.dex = dex;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getPower() {
        return power;
    }

    public void setPower(int power) {
        this.power = power;
    }

    public int getIntelligence() {
        return intelligence;
    }

    public void setIntelligence(int intelligence) {
        this.intelligence = intelligence;
    }

    public int getDex() {
        return dex;
    }

    public void setDex(int dex) {
        this.dex = dex;
    }
}
